package com.jouwee.paranoia;

import org.bukkit.command.CommandExecutor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.plugin.java.JavaPlugin;

/**
 *
 * @author Jouwee
 */
public class Paranoia extends JavaPlugin implements CommandExecutor, Listener {
    
    /** Log handler */
    private LogHandler logHandler;
    
    @Override
    public void onEnable() {
        getLogger().info("Initializing Paranoia...");
        super.onEnable();
        // Instantiates the log handler
        logHandler = new LogHandler();
        // Register this plugin as a listener
        getServer().getPluginManager().registerEvents(this, this);
        
        getLogger().info("Paranoia initialized!");
    }

    @Override
    public void onDisable() {
        getLogger().info("Finalizing paranoia...");
        super.onDisable();
        getLogger().info("Paranoia finalized!");
    }
    
    @EventHandler
    public void onBlockPlace(BlockPlaceEvent event){
        logHandler.add(new BlockEvent(event));
    }
    
    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
        logHandler.add(new BlockEvent(event));
    }
}
